
import { camelCase } from 'lodash';
import wiiEvent from 'utils/Event.js';
import cos from 'utils/cos.js';
import {get,post} from 'utils/request.js';
import {config} from './config.js';

import './components/rate/index.less';
import './components/upload/index.less';
import './components/countdown/index.less';
import './components/flex/index.less';
import './components/abnormal/index.less';
import './components/popup/index.less';
import './components/progress/index.less';
import './components/filter/index.less';
import './components/scroller/index.less';
import './components/ordercard/index.less';
import './components/cityswitch/index.less';

import './components/uploader/index.less';

require('./images/main.png');
require('./images/main_active.png');
require('./images/my.png');
require('./images/my_active.png');

App({
	onLaunch() {

		console.log(camelCase('OnLaunch'));

		// 调用API从本地缓存中获取数据
		const logs = wx.getStorageSync('logs') || [];
		logs.unshift(Date.now());
		wx.setStorageSync('logs', logs);


		console.log('Event')
		console.log(Event)
		console.log('Event')
		this.wiiEvent.on('tab', tab => {
		  console.log('父级'+tab);
		});
	},
	getUserInfo(cb) {
		if (this.globalData.userInfo) {
			typeof cb === 'function' && cb(this.globalData.userInfo);
		} else {
			// 调用登录接口
			wx.login({
				success: () => {
					wx.getUserInfo({
						success: (res) => {
							this.globalData.userInfo = res.userInfo;
							typeof cb === 'function' && cb(this.globalData.userInfo);
						},
					});
				},
			});
		}
	},
	wiiEvent: wiiEvent,
	utils: {
		cos: cos,
		request: {
			get: get,
			post: post
		},
		config: config()
	},
	globalData: {
		userInfo: null
	}
});
